package com.github.catvod.spider.merge;

import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

public class vg extends vt {
  static final String[] F8;
  
  static final String[] i4;
  
  static final String[] iU;
  
  static final String[] n;
  
  static final String[] oq = new String[] { "applet", "caption", "html", "marquee", "object", "table", "td", "th" };
  
  static final String[] t;
  
  static final String[] y;
  
  private boolean C4;
  
  private boolean GM;
  
  private String[] Ig = new String[] { null };
  
  private ArrayList<Lm> LW;
  
  private List<String> Og;
  
  private Ib PD;
  
  @Nullable
  private Lm PU;
  
  private B.qM R;
  
  private boolean b;
  
  private boolean f;
  
  private Ib j5;
  
  @Nullable
  private Lm w4;
  
  @Nullable
  private mx yx;
  
  static {
    F8 = new String[] { "ol", "ul" };
    t = new String[] { "button" };
    n = new String[] { "html", "table" };
    iU = new String[] { "optgroup", "option" };
    i4 = new String[] { "dd", "dt", "li", "optgroup", "option", "p", "rp", "rt" };
    y = new String[] { 
        "address", "applet", "area", "article", "aside", "base", "basefont", "bgsound", "blockquote", "body", 
        "br", "button", "caption", "center", "col", "colgroup", "command", "dd", "details", "dir", 
        "div", "dl", "dt", "embed", "fieldset", "figcaption", "figure", "footer", "form", "frame", 
        "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", 
        "hr", "html", "iframe", "img", "input", "isindex", "li", "link", "listing", "marquee", 
        "menu", "meta", "nav", "noembed", "noframes", "noscript", "object", "ol", "p", "param", 
        "plaintext", "pre", "script", "section", "select", "style", "summary", "table", "tbody", "td", 
        "textarea", "tfoot", "th", "thead", "title", "tr", "ul", "wbr", "xmp" };
  }
  
  private boolean F(String[] paramArrayOfString1, String[] paramArrayOfString2, String[] paramArrayOfString3) {
    byte b;
    int i = this.I.size() - 1;
    if (i > 100) {
      b = i - 100;
    } else {
      b = 0;
    } 
    while (i >= b) {
      String str = ((Lm)this.I.get(i)).w();
      if (ZG.q(str, paramArrayOfString1))
        return true; 
      if (ZG.q(str, paramArrayOfString2))
        return false; 
      if (paramArrayOfString3 != null && ZG.q(str, paramArrayOfString3))
        return false; 
      i--;
    } 
    return false;
  }
  
  private void HU(fa paramfa) {
    if (this.I.isEmpty()) {
      this.q.rl(paramfa);
    } else if (r4()) {
      ap(paramfa);
    } else {
      h().rl(paramfa);
    } 
    if (paramfa instanceof Lm) {
      paramfa = paramfa;
      if (paramfa.XA().oC()) {
        mx mx1 = this.yx;
        if (mx1 != null)
          mx1.Kg((Lm)paramfa); 
      } 
    } 
  }
  
  private boolean N(Lm paramLm1, Lm paramLm2) {
    boolean bool;
    if (paramLm1.w().equals(paramLm2.w()) && paramLm1.I().equals(paramLm2.I())) {
      bool = true;
    } else {
      bool = false;
    } 
    return bool;
  }
  
  private void XA(ArrayList<Lm> paramArrayList, Lm paramLm1, Lm paramLm2) {
    boolean bool;
    int i = paramArrayList.lastIndexOf(paramLm1);
    if (i != -1) {
      bool = true;
    } else {
      bool = false;
    } 
    R2.j(bool);
    paramArrayList.set(i, paramLm2);
  }
  
  private void n(String... paramVarArgs) {
    for (int i = this.I.size() - 1; i >= 0; i--) {
      Lm lm = this.I.get(i);
      if (ZG.j(lm.w(), paramVarArgs) || lm.w().equals("html"))
        break; 
      this.I.remove(i);
    } 
  }
  
  private boolean s(ArrayList<Lm> paramArrayList, Lm paramLm) {
    byte b;
    int i = paramArrayList.size() - 1;
    if (i >= 256) {
      b = i - 256;
    } else {
      b = 0;
    } 
    while (i >= b) {
      if ((Lm)paramArrayList.get(i) == paramLm)
        return true; 
      i--;
    } 
    return false;
  }
  
  private boolean z(String paramString, String[] paramArrayOfString1, String[] paramArrayOfString2) {
    String[] arrayOfString = this.Ig;
    arrayOfString[0] = paramString;
    return F(arrayOfString, paramArrayOfString1, paramArrayOfString2);
  }
  
  void B(Lm paramLm, int paramInt) {
    F8(paramLm);
    this.LW.add(paramInt, paramLm);
  }
  
  boolean C(Lm paramLm) {
    return ZG.q(paramLm.w(), y);
  }
  
  Lm C4() {
    return this.PU;
  }
  
  Lm DQ() {
    int i = this.LW.size();
    return (i > 0) ? this.LW.remove(i - 1) : null;
  }
  
  Lm E(B.x paramx) {
    iP iP = iP.iU(paramx.C4(), this.W);
    Lm lm = new Lm(iP, null, this.W.V0(paramx.Qy));
    HU(lm);
    if (paramx.b())
      if (iP.W()) {
        if (!iP.I())
          this.j.j5("Tag cannot be self closing; not a void tag"); 
      } else {
        iP.t();
      }  
    return lm;
  }
  
  void F8(Lm paramLm) {
    int i = this.LW.size() - 1;
    int j;
    for (j = 0; i >= 0; j = k) {
      Lm lm = this.LW.get(i);
      if (lm == null)
        break; 
      int k = j;
      if (N(paramLm, lm))
        k = j + 1; 
      if (k == 3) {
        this.LW.remove(i);
        break;
      } 
      i--;
    } 
  }
  
  Lm FE(B.x paramx) {
    if (paramx.R() && !paramx.Qy.isEmpty() && paramx.Qy.Qy(this.W) > 0)
      j("Duplicate attribute"); 
    if (paramx.b()) {
      lm = E(paramx);
      this.I.add(lm);
      this.j.w4(xb.h);
      this.j.t(this.R.nf().f(lm.MC()));
      return lm;
    } 
    Lm lm = new Lm(iP.iU(lm.C4(), this.W), null, this.W.V0(((B.j)lm).Qy));
    hr(lm);
    return lm;
  }
  
  boolean GM() {
    return this.b;
  }
  
  void Gg(Lm paramLm) {
    for (int i = this.LW.size() - 1; i >= 0; i--) {
      if ((Lm)this.LW.get(i) == paramLm) {
        this.LW.remove(i);
        break;
      } 
    } 
  }
  
  boolean H9(String paramString) {
    return z(paramString, n, null);
  }
  
  ArrayList<Lm> Ig() {
    return this.I;
  }
  
  void J(mx parammx) {
    this.yx = parammx;
  }
  
  void K(Lm paramLm1, Lm paramLm2) {
    XA(this.LW, paramLm1, paramLm2);
  }
  
  void Kg(boolean paramBoolean) {
    this.C4 = paramBoolean;
  }
  
  void L0(Ib paramIb) {
    this.PD = paramIb;
  }
  
  String LW() {
    return this.oC;
  }
  
  void M() {
    this.LW.add(null);
  }
  
  void MC(Lm paramLm1, Lm paramLm2) {
    XA(this.I, paramLm1, paramLm2);
  }
  
  Lm O() {
    Lm lm;
    if (this.LW.size() > 0) {
      ArrayList<Lm> arrayList = this.LW;
      lm = arrayList.get(arrayList.size() - 1);
    } else {
      lm = null;
    } 
    return lm;
  }
  
  HZ Og() {
    return this.q;
  }
  
  int Oh(Lm paramLm) {
    for (byte b = 0; b < this.LW.size(); b++) {
      if (paramLm == this.LW.get(b))
        return b; 
    } 
    return -1;
  }
  
  void P() {
    Lm lm1 = O();
    if (lm1 == null || a(lm1))
      return; 
    int i = this.LW.size();
    boolean bool = true;
    int k = i - 1;
    i = k;
    while (i != 0) {
      ArrayList<Lm> arrayList = this.LW;
      int m = i - 1;
      Lm lm4 = arrayList.get(m);
      Lm lm3 = lm4;
      i = m;
      if (lm4 != null) {
        lm3 = lm4;
        i = m;
        if (a(lm4)) {
          i = m;
          lm3 = lm4;
        } else {
          continue;
        } 
      } 
      bool = false;
      break;
    } 
    int j = i;
    if (!bool) {
      ArrayList<Lm> arrayList = this.LW;
      j = i + 1;
      lm1 = arrayList.get(j);
    } 
    R2.u(lm1);
    Lm lm2 = d1(lm1.w());
    lm2.I().I(lm1.I());
    this.LW.set(j, lm2);
    i = j;
    if (j == k)
      return; 
    bool = false;
    break;
  }
  
  void PD(Ib paramIb) {
    if (this.h.h().h())
      this.h.h().add(new lA(this.V0.V(), "Unexpected token [%s] when in state [%s]", new Object[] { this.BQ.iU(), paramIb })); 
  }
  
  void PU() {
    yx(null);
  }
  
  boolean Pi(Lm paramLm) {
    for (int i = this.I.size() - 1; i >= 0; i--) {
      if ((Lm)this.I.get(i) == paramLm) {
        this.I.remove(i);
        return true;
      } 
    } 
    return false;
  }
  
  mx R() {
    return this.yx;
  }
  
  Lm S(String paramString) {
    for (int i = this.I.size() - 1; i >= 0; i--) {
      Lm lm = this.I.get(i);
      this.I.remove(i);
      if (lm.w().equals(paramString))
        return lm; 
    } 
    return null;
  }
  
  void SS(Lm paramLm1, Lm paramLm2) {
    boolean bool;
    int i = this.I.lastIndexOf(paramLm1);
    if (i != -1) {
      bool = true;
    } else {
      bool = false;
    } 
    R2.j(bool);
    this.I.add(i + 1, paramLm2);
  }
  
  boolean T(String paramString, String[] paramArrayOfString) {
    return z(paramString, oq, paramArrayOfString);
  }
  
  void TD(Lm paramLm) {
    this.PU = paramLm;
  }
  
  boolean To(String paramString) {
    for (int i = this.I.size() - 1; i >= 0; i--) {
      String str = ((Lm)this.I.get(i)).w();
      if (str.equals(paramString))
        return true; 
      if (!ZG.q(str, iU))
        return false; 
    } 
    R2.h("Should not be reachable");
    return false;
  }
  
  Ib U() {
    return this.PD;
  }
  
  boolean V(String[] paramArrayOfString) {
    return F(paramArrayOfString, oq, null);
  }
  
  Qg V0() {
    return Qg.h;
  }
  
  Ib Xu() {
    return this.j5;
  }
  
  void Y(String paramString) {
    for (int i = this.I.size() - 1; i >= 0 && !((Lm)this.I.get(i)).w().equals(paramString); i--)
      this.I.remove(i); 
  }
  
  boolean Yd(B paramB, Ib paramIb) {
    this.BQ = paramB;
    return paramIb.Qy(paramB, this);
  }
  
  boolean a(Lm paramLm) {
    return s(this.I, paramLm);
  }
  
  void ap(fa paramfa) {
    Lm lm1;
    Lm lm2 = b("table");
    boolean bool = false;
    if (lm2 != null) {
      if (lm2.lu() != null) {
        lm1 = lm2.lu();
        bool = true;
      } else {
        lm1 = oq(lm2);
      } 
    } else {
      lm1 = this.I.get(0);
    } 
    if (bool) {
      R2.u(lm2);
      lm2.SS(paramfa);
    } else {
      lm1.rl(paramfa);
    } 
  }
  
  Lm b(String paramString) {
    for (int i = this.I.size() - 1; i >= 0; i--) {
      Lm lm = this.I.get(i);
      if (lm.w().equals(paramString))
        return lm; 
    } 
    return null;
  }
  
  Lm d1(String paramString) {
    Lm lm = new Lm(iP.iU(paramString, this.W), null);
    hr(lm);
    return lm;
  }
  
  void e() {
    int i = this.I.size() - 1;
    boolean bool = false;
    while (i >= 0) {
      String str;
      Lm lm = this.I.get(i);
      if (i == 0) {
        lm = this.w4;
        bool = true;
      } 
      if (lm != null) {
        str = lm.w();
      } else {
        str = "";
      } 
      if ("select".equals(str)) {
        L0(Ib.i4);
        break;
      } 
      if ("td".equals(str) || ("th".equals(str) && !bool)) {
        L0(Ib.iU);
        break;
      } 
      if ("tr".equals(str)) {
        L0(Ib.n);
        break;
      } 
      if ("tbody".equals(str) || "thead".equals(str) || "tfoot".equals(str)) {
        L0(Ib.t);
        break;
      } 
      if ("caption".equals(str)) {
        L0(Ib.oq);
        break;
      } 
      if ("colgroup".equals(str)) {
        L0(Ib.F8);
        break;
      } 
      if ("table".equals(str)) {
        L0(Ib.u);
        break;
      } 
      if ("head".equals(str)) {
        L0(Ib.BQ);
        break;
      } 
      if ("body".equals(str)) {
        L0(Ib.BQ);
        break;
      } 
      if ("frameset".equals(str)) {
        L0(Ib.j5);
        break;
      } 
      if ("html".equals(str)) {
        L0(Ib.j);
        break;
      } 
      if (bool) {
        L0(Ib.BQ);
        break;
      } 
      i--;
    } 
  }
  
  List<String> f() {
    return this.Og;
  }
  
  boolean fR(Lm paramLm) {
    return s(this.LW, paramLm);
  }
  
  boolean g6() {
    return this.f;
  }
  
  void hP() {
    this.j5 = this.PD;
  }
  
  void hr(Lm paramLm) {
    HU(paramLm);
    this.I.add(paramLm);
  }
  
  protected boolean i(String paramString) {
    return (paramString.equals("script") || paramString.equals("style"));
  }
  
  void i4() {
    n(new String[] { "table" });
  }
  
  void iU() {
    n(new String[] { "tbody", "tfoot", "thead", "template" });
  }
  
  void j5(boolean paramBoolean) {
    this.b = paramBoolean;
  }
  
  boolean l(String paramString) {
    return T(paramString, t);
  }
  
  void lu(Lm paramLm) {
    this.I.add(paramLm);
  }
  
  void nO(Lm paramLm) {
    if (this.GM)
      return; 
    String str = paramLm.h("href");
    if (str.length() != 0) {
      this.oC = str;
      this.GM = true;
      this.q.F(str);
    } 
  }
  
  boolean nf(String paramString) {
    return T(paramString, F8);
  }
  
  protected boolean oC(B paramB) {
    this.BQ = paramB;
    return this.PD.Qy(paramB, this);
  }
  
  Lm oq(Lm paramLm) {
    for (int i = this.I.size() - 1; i >= 0; i--) {
      if ((Lm)this.I.get(i) == paramLm)
        return this.I.get(i - 1); 
    } 
    return null;
  }
  
  @ParametersAreNonnullByDefault
  protected void q(Reader paramReader, String paramString, F paramF) {
    super.q(paramReader, paramString, paramF);
    this.PD = Ib.h;
    this.j5 = null;
    this.GM = false;
    this.PU = null;
    this.yx = null;
    this.w4 = null;
    this.LW = new ArrayList<Lm>();
    this.Og = new ArrayList<String>();
    this.R = new B.qM();
    this.b = true;
    this.C4 = false;
    this.f = false;
  }
  
  void qG(B.d paramd) {
    HU(new mF(paramd.j5()));
  }
  
  boolean r4() {
    return this.C4;
  }
  
  Lm rG() {
    int i = this.I.size();
    return this.I.remove(i - 1);
  }
  
  boolean rd(String paramString) {
    return T(paramString, null);
  }
  
  mx rl(B.x paramx, boolean paramBoolean) {
    mx mx1 = new mx(iP.iU(paramx.C4(), this.W), null, this.W.V0(paramx.Qy));
    J(mx1);
    HU(mx1);
    if (paramBoolean)
      this.I.add(mx1); 
    return mx1;
  }
  
  void t() {
    do {
    
    } while (!this.LW.isEmpty() && DQ() != null);
  }
  
  public String toString() {
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("TreeBuilder{currentToken=");
    stringBuilder.append(this.BQ);
    stringBuilder.append(", state=");
    stringBuilder.append(this.PD);
    stringBuilder.append(", currentElement=");
    stringBuilder.append(h());
    stringBuilder.append('}');
    return stringBuilder.toString();
  }
  
  void v(B.HA paramHA) {
    IG iG;
    Lm lm2 = h();
    Lm lm1 = lm2;
    if (lm2 == null)
      lm1 = this.q; 
    String str2 = lm1.w();
    String str1 = paramHA.y();
    if (paramHA.oC()) {
      iG = new ok(str1);
    } else if (i(str2)) {
      BG bG = new BG(str1);
    } else {
      iG = new IG(str1);
    } 
    lm1.rl(iG);
  }
  
  void vm(Lm paramLm) {
    F8(paramLm);
    this.LW.add(paramLm);
  }
  
  void w(String... paramVarArgs) {
    for (int i = this.I.size() - 1; i >= 0; i--) {
      Lm lm = this.I.get(i);
      this.I.remove(i);
      if (ZG.q(lm.w(), paramVarArgs))
        break; 
    } 
  }
  
  Lm w4(String paramString) {
    for (int i = this.LW.size() - 1; i >= 0; i--) {
      Lm lm = this.LW.get(i);
      if (lm == null)
        break; 
      if (lm.w().equals(paramString))
        return lm; 
    } 
    return null;
  }
  
  void y() {
    n(new String[] { "tr", "template" });
  }
  
  void yp() {
    this.Og = new ArrayList<String>();
  }
  
  void yx(String paramString) {
    while (paramString != null && !h().w().equals(paramString) && ZG.q(h().w(), i4))
      rG(); 
  }
}


/* Location:              /Users/hetaiyi/Desktop/my/tech/java/study/aa/temp/temp.jar!/com/github/catvod/spider/merge/vg.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */